package locations.model;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;

@Entity
@Table
public class Pacient extends Persona implements Serializable {

	private static final long serialVersionUID = -8635731102423392639L;
	@OneToOne(cascade = CascadeType.ALL)
	private HistoriaSocial historiaSocial;

	@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true)
	@JoinColumn(name = "location_id")
	protected Location location;

	public Pacient() {
		this.setHistoriaSocial(new HistoriaSocial());
		this.getHistoriaSocial().setPaciente(this);
	}

	public Location getLocation() {
		return location;
	}

	public void setLocation(Location location) {
		this.location = location;
	}

	public boolean isNew() {
		return this.getId() == null;
	}

	public String toString() {

		return this.getNombre() + "," + this.getApellido();
	}

	public HistoriaSocial getHistoriaSocial() {
		return historiaSocial;
	}

	public void setHistoriaSocial(HistoriaSocial historiaSocial) {
		this.historiaSocial = historiaSocial;
	}
  
  public String getName() {
    return this.getNombre();
  }
}
